/* 番茄小说风格移动端设计 */

/* =============== 全局变量定义 =============== */
:root {
  /* 颜色系统 */
  --tomato-primary: #ff6b35;
  --tomato-primary-light: #ff8a65;
  --tomato-primary-dark: #e55722;
  --tomato-secondary: #4a90e2;
  --tomato-success: #52c41a;
  --tomato-warning: #faad14;
  --tomato-error: #f5222d;
  
  /* 中性色调 */
  --tomato-text-primary: #1a1a1a;
  --tomato-text-secondary: #666666;
  --tomato-text-disabled: #999999;
  --tomato-border: #f0f0f0;
  --tomato-background: #fafafa;
  --tomato-card-bg: #ffffff;
  
  /* 阴影系统 */
  --tomato-shadow-card: 0 2px 12px 0 rgba(0, 0, 0, 0.08);
  --tomato-shadow-popup: 0 8px 32px 0 rgba(0, 0, 0, 0.15);
  --tomato-shadow-button: 0 2px 8px 0 rgba(255, 107, 53, 0.3);
  
  /* 圆角系统 */
  --tomato-radius-small: 8px;
  --tomato-radius-medium: 12px;
  --tomato-radius-large: 16px;
  --tomato-radius-xl: 24px;
  
  /* 间距系统 */
  --tomato-space-xs: 4px;
  --tomato-space-sm: 8px;
  --tomato-space-md: 12px;
  --tomato-space-lg: 16px;
  --tomato-space-xl: 20px;
  --tomato-space-2xl: 24px;
  --tomato-space-3xl: 32px;
  
  /* 动画 */
  --tomato-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --tomato-transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --tomato-transition-bounce: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* 深色模式变量 */
@media (prefers-color-scheme: dark) {
  :root {
    --tomato-text-primary: #ffffff;
    --tomato-text-secondary: #cccccc;
    --tomato-text-disabled: #666666;
    --tomato-border: #333333;
    --tomato-background: #1a1a1a;
    --tomato-card-bg: #2a2a2a;
    --tomato-shadow-card: 0 2px 12px 0 rgba(0, 0, 0, 0.3);
    --tomato-shadow-popup: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
  }
}

/* =============== 移动端基础优化 =============== */
@media (max-width: 768px) {
  * {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
  }

  body {
    background: var(--tomato-background);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  /* =============== 现代化卡片系统 =============== */
  .tomato-card {
    background: var(--tomato-card-bg);
    border-radius: var(--tomato-radius-large);
    box-shadow: var(--tomato-shadow-card);
    margin: var(--tomato-space-md);
    overflow: hidden;
    transition: var(--tomato-transition);
    
    &:active {
      transform: scale(0.98);
      box-shadow: 0 1px 6px 0 rgba(0, 0, 0, 0.05);
    }
    
    &.elevated {
      box-shadow: var(--tomato-shadow-popup);
    }
  }
  
  .tomato-card-header {
    padding: var(--tomato-space-xl) var(--tomato-space-xl) var(--tomato-space-lg);
    border-bottom: 1px solid var(--tomato-border);
    
    .card-title {
      font-size: 18px;
      font-weight: 600;
      color: var(--tomato-text-primary);
      margin: 0;
    }
    
    .card-subtitle {
      font-size: 14px;
      color: var(--tomato-text-secondary);
      margin: var(--tomato-space-xs) 0 0;
    }
  }
  
  .tomato-card-body {
    padding: var(--tomato-space-xl);
  }
  
  .tomato-card-footer {
    padding: var(--tomato-space-lg) var(--tomato-space-xl);
    border-top: 1px solid var(--tomato-border);
    background: rgba(0, 0, 0, 0.02);
  }

  /* =============== 现代化按钮系统 =============== */
  .tomato-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--tomato-space-sm);
    padding: var(--tomato-space-md) var(--tomato-space-xl);
    border: none;
    border-radius: var(--tomato-radius-large);
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: var(--tomato-transition);
    min-height: 48px;
    position: relative;
    overflow: hidden;
    
    &::before {
      content: '';
      position: absolute;
      top: 50%;
      left: 50%;
      width: 0;
      height: 0;
      background: rgba(255, 255, 255, 0.3);
      border-radius: 50%;
      transition: all 0.3s;
      transform: translate(-50%, -50%);
    }
    
    &:active::before {
      width: 200px;
      height: 200px;
    }
    
    &.primary {
      background: linear-gradient(135deg, var(--tomato-primary), var(--tomato-primary-dark));
      color: white;
      box-shadow: var(--tomato-shadow-button);
      
      &:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 16px 0 rgba(255, 107, 53, 0.4);
      }
      
      &:active {
        transform: translateY(0);
      }
    }
    
    &.secondary {
      background: var(--tomato-card-bg);
      color: var(--tomato-text-primary);
      border: 2px solid var(--tomato-border);
      
      &:hover {
        border-color: var(--tomato-primary);
        color: var(--tomato-primary);
      }
    }
    
    &.ghost {
      background: transparent;
      color: var(--tomato-primary);
      border: 2px solid var(--tomato-primary);
      
      &:hover {
        background: var(--tomato-primary);
        color: white;
      }
    }
    
    &.round {
      border-radius: 50px;
    }
    
    &.small {
      padding: var(--tomato-space-sm) var(--tomato-space-lg);
      font-size: 14px;
      min-height: 36px;
    }
    
    &.large {
      padding: var(--tomato-space-lg) var(--tomato-space-2xl);
      font-size: 18px;
      min-height: 56px;
    }
    
    &:disabled {
      opacity: 0.5;
      cursor: not-allowed;
      transform: none !important;
      
      &:hover {
        transform: none;
        box-shadow: none;
      }
    }
  }

  /* =============== 优雅的弹窗系统 =============== */
  .tomato-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--tomato-space-xl);
    
    &.enter-active {
      animation: modalEnter 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    &.leave-active {
      animation: modalLeave 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
  }
  
  .tomato-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
  }
  
  .tomato-modal-content {
    position: relative;
    background: var(--tomato-card-bg);
    border-radius: var(--tomato-radius-xl);
    box-shadow: var(--tomato-shadow-popup);
    max-width: 400px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    transform: scale(1);
    
    .modal-header {
      padding: var(--tomato-space-2xl) var(--tomato-space-xl) var(--tomato-space-lg);
      border-bottom: 1px solid var(--tomato-border);
      position: relative;
      
      .modal-title {
        font-size: 20px;
        font-weight: 700;
        color: var(--tomato-text-primary);
        margin: 0;
        text-align: center;
      }
      
      .modal-close {
        position: absolute;
        top: var(--tomato-space-lg);
        right: var(--tomato-space-lg);
        width: 32px;
        height: 32px;
        border: none;
        background: rgba(0, 0, 0, 0.05);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: var(--tomato-transition);
        
        &:hover {
          background: rgba(0, 0, 0, 0.1);
          transform: scale(1.1);
        }
      }
    }
    
    .modal-body {
      padding: var(--tomato-space-xl);
      max-height: 60vh;
      overflow-y: auto;
      
      /* 自定义滚动条 */
      &::-webkit-scrollbar {
        width: 4px;
      }
      
      &::-webkit-scrollbar-track {
        background: var(--tomato-border);
        border-radius: 2px;
      }
      
      &::-webkit-scrollbar-thumb {
        background: var(--tomato-primary);
        border-radius: 2px;
        
        &:hover {
          background: var(--tomato-primary-dark);
        }
      }
    }
    
    .modal-footer {
      padding: var(--tomato-space-lg) var(--tomato-space-xl) var(--tomato-space-xl);
      border-top: 1px solid var(--tomato-border);
      display: flex;
      gap: var(--tomato-space-md);
      
      .tomato-btn {
        flex: 1;
      }
    }
  }

  @keyframes modalEnter {
    from {
      opacity: 0;
      transform: scale(0.9);
    }
    to {
      opacity: 1;
      transform: scale(1);
    }
  }
  
  @keyframes modalLeave {
    from {
      opacity: 1;
      transform: scale(1);
    }
    to {
      opacity: 0;
      transform: scale(0.9);
    }
  }

  /* =============== 现代化列表系统 =============== */
  .tomato-list {
    background: var(--tomato-card-bg);
    border-radius: var(--tomato-radius-large);
    box-shadow: var(--tomato-shadow-card);
    margin: var(--tomato-space-md);
    overflow: hidden;
  }
  
  .tomato-list-item {
    display: flex;
    align-items: center;
    padding: var(--tomato-space-lg);
    border-bottom: 1px solid var(--tomato-border);
    transition: var(--tomato-transition-fast);
    cursor: pointer;
    
    &:last-child {
      border-bottom: none;
    }
    
    &:active {
      background: rgba(0, 0, 0, 0.02);
    }
    
    &.with-arrow::after {
      content: '›';
      margin-left: auto;
      font-size: 20px;
      color: var(--tomato-text-disabled);
    }
    
    .item-avatar {
      width: 48px;
      height: 48px;
      border-radius: var(--tomato-radius-medium);
      margin-right: var(--tomato-space-md);
      overflow: hidden;
      background: var(--tomato-border);
      
      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
    }
    
    .item-content {
      flex: 1;
      min-width: 0;
      
      .item-title {
        font-size: 16px;
        font-weight: 600;
        color: var(--tomato-text-primary);
        margin: 0 0 var(--tomato-space-xs);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      
      .item-desc {
        font-size: 14px;
        color: var(--tomato-text-secondary);
        margin: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
    
    .item-extra {
      margin-left: var(--tomato-space-md);
      color: var(--tomato-text-secondary);
      font-size: 14px;
    }
  }

  /* =============== 优雅的导航栏 =============== */
  .tomato-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--tomato-border);
    transition: var(--tomato-transition);
    
    &.scrolled {
      box-shadow: var(--tomato-shadow-card);
    }
    
    .navbar-content {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: var(--tomato-space-md) var(--tomato-space-lg);
      min-height: 56px;
      
      .navbar-back {
        width: 40px;
        height: 40px;
        border: none;
        background: rgba(0, 0, 0, 0.05);
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: var(--tomato-transition);
        
        &:hover {
          background: rgba(0, 0, 0, 0.1);
          transform: scale(1.05);
        }
        
        &:active {
          transform: scale(0.95);
        }
      }
      
      .navbar-title {
        font-size: 18px;
        font-weight: 700;
        color: var(--tomato-text-primary);
        text-align: center;
        flex: 1;
        margin: 0 var(--tomato-space-lg);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      
      .navbar-action {
        width: 40px;
        height: 40px;
        border: none;
        background: none;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: var(--tomato-transition);
        border-radius: 50%;
        
        &:hover {
          background: rgba(0, 0, 0, 0.05);
        }
      }
    }
  }

  /* =============== 底部安全区域适配 =============== */
  .tomato-safe-bottom {
    padding-bottom: max(var(--tomato-space-lg), env(safe-area-inset-bottom));
  }
  
  .tomato-safe-top {
    padding-top: max(var(--tomato-space-lg), env(safe-area-inset-top));
  }

  /* =============== 表单优化 =============== */
  .tomato-form-item {
    margin-bottom: var(--tomato-space-xl);
    
    .form-label {
      display: block;
      font-size: 16px;
      font-weight: 600;
      color: var(--tomato-text-primary);
      margin-bottom: var(--tomato-space-sm);
    }
    
    .form-input,
    .form-textarea {
      width: 100%;
      padding: var(--tomato-space-lg);
      border: 2px solid var(--tomato-border);
      border-radius: var(--tomato-radius-medium);
      font-size: 16px;
      background: var(--tomato-card-bg);
      color: var(--tomato-text-primary);
      transition: var(--tomato-transition);
      
      &:focus {
        outline: none;
        border-color: var(--tomato-primary);
        box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.1);
      }
      
      &::placeholder {
        color: var(--tomato-text-disabled);
      }
    }
    
    .form-textarea {
      min-height: 120px;
      resize: vertical;
    }
  }

  /* =============== 加载状态 =============== */
  .tomato-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--tomato-space-3xl);
    
    .loading-spinner {
      width: 32px;
      height: 32px;
      border: 3px solid var(--tomato-border);
      border-top: 3px solid var(--tomato-primary);
      border-radius: 50%;
      animation: spin 1s linear infinite;
    }
    
    .loading-text {
      margin-left: var(--tomato-space-md);
      color: var(--tomato-text-secondary);
      font-size: 14px;
    }
  }
  
  @keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }

  /* =============== 消息提示 =============== */
  .tomato-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: var(--tomato-space-lg) var(--tomato-space-xl);
    border-radius: var(--tomato-radius-large);
    font-size: 16px;
    z-index: 2000;
    max-width: 80%;
    text-align: center;
    
    &.success {
      background: var(--tomato-success);
    }
    
    &.error {
      background: var(--tomato-error);
    }
    
    &.warning {
      background: var(--tomato-warning);
    }
  }
}

/* =============== 特殊组件样式 =============== */

/* 章节列表优化 */
.chapter-list.tomato-style {
  .chapter-item {
    border-radius: var(--tomato-radius-medium);
    transition: var(--tomato-transition);
    margin-bottom: var(--tomato-space-sm);
    background: var(--tomato-card-bg);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    
    &:hover {
      transform: translateX(4px);
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    &.reading {
      background: linear-gradient(135deg, var(--tomato-primary), var(--tomato-primary-light));
      color: white;
      
      .chapter-title {
        color: white;
      }
    }
  }
}

/* 小说卡片优化 */
.novel-card.tomato-style {
  background: var(--tomato-card-bg);
  border-radius: var(--tomato-radius-large);
  box-shadow: var(--tomato-shadow-card);
  padding: var(--tomato-space-lg);
  border: 1px solid var(--tomato-border);
  transition: var(--tomato-transition);
  
  &:hover {
    box-shadow: var(--tomato-shadow-popup);
    transform: translateY(-2px);
  }
  
  .novel-cover {
    border-radius: var(--tomato-radius-medium);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
  
  .novel-info {
    .novel-title {
      font-size: 16px;
      font-weight: 700;
      color: var(--tomato-text-primary);
      margin-bottom: var(--tomato-space-xs);
    }
    
    .novel-author {
      font-size: 14px;
      color: var(--tomato-text-secondary);
    }
    
    .novel-stats {
      display: flex;
      gap: var(--tomato-space-md);
      margin-top: var(--tomato-space-sm);
      
      .stat-item {
        font-size: 12px;
        color: var(--tomato-text-disabled);
      }
    }
  }
}

/* 阅读器底部控制栏优化 */
.reader-controls.tomato-style {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--tomato-border);
  
  .control-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: var(--tomato-text-secondary);
    border: none;
    cursor: pointer;
    transition: var(--tomato-transition);
    padding: var(--tomato-space-sm);
    min-height: 44px;
    border-radius: var(--tomato-radius-medium);
    flex-direction: column;
    font-size: 12px;
    
    &:hover {
      background: var(--tomato-background);
      color: var(--tomato-text-primary);
    }
    
    &:disabled {
      opacity: 0.3;
      color: var(--tomato-text-disabled);
    }
    
    svg {
      margin-bottom: var(--tomato-space-xs);
    }
  }
} 